package com.domel76.quickfilm.common;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class URLLoader {

	public String urlGet(String urlString) {

		URLConnection urlConnection = null;
		URL url = null;
		String string = null;

		try {
			url = new URL(urlString);
			urlConnection = url.openConnection();

			InputStream inputStream = urlConnection.getInputStream();
			InputStreamReader inputStreamReader = new InputStreamReader(inputStream,"ISO-8859-2");
			BufferedReader reader = new BufferedReader(inputStreamReader);

			StringBuffer stringBuffer = new StringBuffer();

			while ((string = reader.readLine()) != null) {
				stringBuffer.append(string + "\n");
			}
			inputStream.close();

			string = stringBuffer.toString();

		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

		return string;
	}
}
